<template>
  <div class="app-container">
    <!-- 工具栏 -->
    <!-- <tl-list-toolbar ref="toolbar" :isDisplayAdd="editable" :isDisplayExport="false" :isDisplayDeleteBatch="editable" @add="openAddDialog('editForm')" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :disableDeleteBatch="selectedRowKeys.length <= 0">
      <template slot="left-btn">
        <el-button class="filter-item" type="primary" icon="el-icon-plus" @click="openAddDialog('editTemplateForm')" v-show="editable">按模板新增</el-button>
        <el-button class="filter-item" type="primary" icon="el-icon-plus" :projectinfo="projectinfo" @click="openAddDialog('editProjectForm')" v-show="editable">按项目新增</el-button>
      </template>
    </tl-list-toolbar> -->
    <tl-list-search style="margin:6px 0" ref="search" :query-param="queryParam" @search="doQuery" :isDisplayDefaultSearch="false" v-if="isHeaderDisplay">
      <template slot="search">
        <el-form-item class="qryItem" label="项目" style="margin-left:-12px">
          <el-input v-model="queryParam.qry_projectstr" placeholder="名称或编号" @keyup.enter.native="doQuery"> </el-input>
        </el-form-item>
        <el-form-item class="qryItem" label="责任人">
          <el-input v-model="queryParam.qry_responsiblestr" placeholder="名字或工号" @keyup.enter.native="doQuery"> </el-input>
        </el-form-item>
      </template>
    </tl-list-search>
    <!-- <tl-list-toolbar ref="toolbar" @add="openAddDialog('editForm')" :isDisplayAdd="false" :isDisplayDeleteBatch="false" :isDisplayExport="false" :isDisplayRight="false" @exportExcel="doExportExcel" @deleteBatch="doDeleteBatch" @refresh="doRefresh" @columnCustomize="doColumnCustomize" @displaySearch="doDisplaySearch" :disableDeleteBatch="selectedRowKeys.length <= 0">
      <template slot="left-btn"> </template>
    </tl-list-toolbar> -->
    <div>
      <!-- 列表选择 -->
      <div class="table-alert-div" ref="selector">
        <el-alert type="success" :closable="false" class="tl-table-alert-info" effect="light">
          <template slot="title">
            已选择&nbsp;<a class="tl-table-alert-info-a1">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
            <a class="tl-table-alert-info-a2" @click="doClearSelected">全部清空</a>
          </template>
        </el-alert>
      </div>
      <!--表格渲染-->
      <el-table class="tl-table" ref="mainTable" :height="tableHeight" resizable-key="tableHeight" :resizable-refs="tableResizeRefs" v-loading="loading" :data="datas" @selection-change="doSelectChange" @sort-change="doSortChange" @row-dblclick="doRowDbClick" @row-click="doRowClick" row-key="id" border fit :row-class-name="doChangeRowClassName">
        <!-- <el-table-column type="selection" width="50px" fixed="left"></el-table-column> -->
        <el-table-column type="index" label="序号" width="50px" align="center"></el-table-column>
        <el-table-column prop="deptname" label="所属部门" width="95px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="projectcode" label="项目编号" width="150px" sortable="custom" sort-by="projectcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="projectname" label="项目名称" width="250px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispprojectlevel" label="项目级别" width="80px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="projectmanager" label="项目经理" width="80px" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="milepostname" label="里程碑及任务名称" width="150px" sortable="custom" sort-by="milepostname" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="deliverable" label="交付成果" min-width="200px" sortable="custom" sort-by="deliverable" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <!-- <el-table-column prop="dispmilepoststate" label="里程碑及任务状态" width="100px" sortable="custom" sort-by="milepoststate" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
        <el-table-column prop="responsible" label="责任人" width="65px" sortable="custom" sort-by="responsible" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="planfinishtime" label="计划达成日期" width="105px" sortable="custom" sort-by="planfinishtime" align="center" header-align="center" :show-overflow-tooltip="true" :formatter="dateFormat"></el-table-column>
        <el-table-column prop="unfinishedtask" label="未完成任务" width="150px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <!-- <el-table-column prop="dispactualfinishtime" label="实际达成时间" width="160px" sortable="custom" sort-by="actualfinishtime" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
        <!-- <el-table-column prop="sourcetype" label="来源类型" width="150px" sortable="custom" sort-by="sourcetype" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="sourceid" label="来源id" width="150px" sortable="custom" sort-by="sourceid" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="milepostcode" label="编码" width="150px" sortable="custom" sort-by="milepostcode" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="dispmilepoststate" label="里程碑及任务状态" width="100px" sortable="custom" sort-by="milepoststate" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="state" label="审批状态" width="150px" sortable="custom" sort-by="state" align="center" header-align="center" :show-overflow-tooltip="true"></el-table-column>
        <el-table-column prop="description" label="备注" min-width="250px" align="left" header-align="center" :show-overflow-tooltip="true"></el-table-column> -->
        <!-- <el-table-column prop="enabled" label="有效" width="100px" sortable="custom" sort-by="enabled" align="center" header-align="center">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.enabled === 1" type="success">是</el-tag>
            <el-tag v-else type="danger">否</el-tag>
          </template>
        </el-table-column> -->
        <el-table-column label="操作" width="100px" v-slot="scope" fixed="right">
          <el-dropdown trigger="hover">
            <el-button type="text" icon="el-icon-s-operation" style="margin-left:10px">更多<i class="el-icon-arrow-down el-icon--right"></i></el-button>
            <el-dropdown-menu>
              <!-- <el-dropdown-item icon="el-icon-edit" @click.native="openEditDialog('editForm', scope.row.id)" :disabled="scope.row.milepoststate !== 1">编辑</el-dropdown-item> -->
              <!-- <el-dropdown-item icon="el-icon-delete" :disabled="scope.row.milepoststate !== 1" @click.native="doDelete(scope.row.id)">删除</el-dropdown-item> -->
              <el-dropdown-item icon="el-icon-view" @click.native="openViewDialog('editForm', scope.row.id)">查看 </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </el-table-column>
      </el-table>
      <!-- 列表分页 -->
      <el-row class="pagebar" ref="pager">
        <el-pagination @size-change="doChangeSize" @current-change="doChangeIndex" :current-page="pageInfo.currentPage" :page-sizes="pageInfo.pageSizes" :total="pageInfo.totalCount" layout="total, sizes, prev, pager, next, jumper" background class="tl-table-pagination"> </el-pagination>
      </el-row>
      <tl-edit ref="editForm" @refresh="doRefresh" :parentId="parentId" :projectinfo="projectinfo"></tl-edit>
      <tl-edit-template ref="editTemplateForm" @refresh="doRefresh" :parentId="parentId" :projectinfo="projectinfo"></tl-edit-template>
      <tl-edit-project ref="editProjectForm" @refresh="doRefresh" :parentId="parentId" :projectinfo="projectinfo"></tl-edit-project>
    </div>
  </div>
</template>

<script>
/** mixins */
import { mixin_list } from '@tapui/mixins/mixin_list'
/** 子组件 */
import tlEdit from './edit'
import tlEditTemplate from './editTemplate'
import tlEditProject from './editProject'
import { checkPermission } from '@tapui/utils/permission'
/** 工具类 */
import { getAction, putAction, postAction, deleteAction } from '@tapui/utils/http'
import { filterObjectNull } from '@tapui/utils/util'
export default {
  name: 'mpmProjectMilepost',
  mixins: [mixin_list],
  components: { tlEdit, tlEditTemplate, tlEditProject },
  data() {
    return {
      description: '项目策划-里程碑及任务-列表查询',
      urlPrefix: '/mpm/projectMilepost/',
      url: {
        // queryCodeList: '/mpm/projectMilepost/dataCodeList'
        list: '/mpm/projectMilepost/list',
        load: '/mpm/projectMilepost/load'
      },
      // 排序参数
      sorterInfo: {
        sidx: 'sortcode',
        sord: 'asc'
      },
      datas: [],
      operatecode: '',
      reduceHeight: 150
    }
  },
  props: {
    parentId: {
      type: [Number, String],
      default: ''
    },
    editable: {
      type: Boolean,
      default: true
    },
    projectinfo: {}
  },
  methods: {
    /** 表格双击事件 */
    doRowDbClick(row, column, event) {
      if (this.rowDbClickActionType === 'edit') {
        // 判断是否有权限
        if (this.editPermission.length > 0) {
          if (checkPermission(this.editPermission)) {
            this.openViewDialog('editForm', row[this.$refs.mainTable.rowKey])
          } else {
            this.openViewDialog('editForm', row[this.$refs.mainTable.rowKey])
          }
        } else {
          this.openViewDialog('editForm', row[this.$refs.mainTable.rowKey])
        }
      } else if (this.rowDbClickActionType === 'view') {
        this.openViewDialog('editForm', row[this.$refs.mainTable.rowKey])
      }
    },
    getQueryParams() {
      let param = {}
      if (this.superQueryParams) {
        param['superQueryParams'] = encodeURI(this.superQueryParams)
      }
      Object.assign(param, this.queryParam, this.sorterInfo, this.filtersInfo)
      param.currentPage = this.pageInfo.currentPage
      param.pageSize = this.pageInfo.pageSize
      param.qry_permission = this.$route.params.qry_permission
      param.qry_overdue = this.$route.params.qry_overdue
      param.qry_milepoststate = 0
      param.qry_enabled = 1
      return filterObjectNull(param)
    },
    initPage() {
      if (this.editable) {
        this.rowDbClickActionType = 'edit'
      } else {
        this.rowDbClickActionType = 'view'
      }
    },
    created() { }
  }
}
</script>
<style scoped></style>
